﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Maticsoft.DBUtility;
namespace BLL.ManageDBLNo
{
    public class ManageLast6Code
    {
        public static int UpdateLast6Code(List<string> list, bool isAvailable)
        {
            int affectCount = 0;
            string ar = string.Empty;
            if (isAvailable == true)
            {
                ar = "A";
            }
            else
            {
                ar = "R";
            }

            for (int i = 0; i < list.Count; i++)
            {
                string sqlstr = @"update b_last6code 
                                    set availablereserve = '" + ar + @"' 
                                    where last6code like '%" + list[i] + "%'";

                int count = DbHelperOra.ExecuteSql(sqlstr);
                affectCount += count;
            }
            return affectCount;
        }

        public static DataSet GetAllLast6Code()
        {
            return DbHelperOra.Query("select * from b_last6code");
        }

        public static DataSet GetAllLast6CodeReserve()
        {
            return DbHelperOra.Query("select * from b_last6code where availablereserve = 'R'");
        }

        public static DataSet GetLast6Code(string strLike)
        {
            string sqlstr = "select * from b_last6code ";
            if (!strLike.Equals(""))
            {
                sqlstr = sqlstr + " where last6code like'%" + strLike + "%'";
            }
            return DbHelperOra.Query(sqlstr);
        }
    }
}
